const router = require('koa-router')() // 一边导入一边实例化
const result = require('../../config/result.js')
const { regcheck, checking } = require('../../config/checking.js')
const bodyParser = require('koa-bodyparser')
// 操作数据库的接口
const { getToken, Addurl } = require('../../config/databaseapi.js')
// 注册接口
router.post('/addannouncement', async (ctx) => {
    console.log("调用发布公告接口");
    console.log(ctx.request.body);
    const res = await new getToken().posteve(Addurl,`db.collection("announcement").add({data:${JSON.stringify(ctx.request.body)}})`)
    if (res.errcode === 0) {
        ctx.body = { msg: "添加成功", status: 1 }
    } else {
        ctx.body = { msg: "添加失败", status: 0 }
    }
})

module.exports = router.routes()